using AutoMapper;
using SapaFinance.DTO;
using SapaFinance.Domain.Model;

namespace SapaFinance.OOMap.Helpers
{
    public class CorporationToCorporationDTOConvert : TypeConverter<Corporation, CorporationDTO>
    {

        protected override CorporationDTO ConvertCore(Corporation corporation)
        {
            var dto = new CorporationDTO();
            if (corporation != null)
            {
                dto.UID=corporation.UID;
                dto.Name = corporation.Name;
                dto.FullName=corporation.FullName;
                dto.SelectedAgent = corporation.Agent.UID;
                dto.LegalAddress = corporation.LegalAddress;
                dto.Tin = corporation.Tin;
                dto.Kpp = corporation.Kpp;
                dto.Okonh = corporation.Okonh;
                dto.Okpo = corporation.Okpo;
                dto.AccountantName = corporation.AccountantName;
                dto.DirectorName = corporation.DirectorName;
                dto.ActualAddress = corporation.ActualAddress;
                dto.Description = corporation.Description;
                dto.RegistrationDate = corporation.RegistrationDate;
                dto.IsHidden = corporation.IsHidden;
                dto.Created = corporation.CreatedBy.DateTime;
                dto.CreatedBy = corporation.CreatedBy.User.FullName;
                dto.Changed = corporation.ChangedBy.DateTime;
                dto.ChangedBy = corporation.ChangedBy.User.FullName;
                dto.IsPayer = corporation.IsPayer;
            }
            return dto;
        }
    }
}